package com.hison.tandainbao.controller;

import com.hison.tandainbao.entiy.pojo.domain.TbLocalevent;
import com.hison.tandainbao.entiy.pojo.dto.TbLocaleventDto;
import com.hison.tandainbao.response.ResponseResult;
import com.hison.tandainbao.service.TbLocaleventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: LocaleventController
 * @Descripiton: 本地活动信息控制类
 * @Author: 小郑
 * @Date： 2024/3/29 22:59
 * @Version：1.8
 **/
@RestController
@RequestMapping("/localEvent")
@Api(value = "本地活动信息管理接口", tags = "本地活动信息管理接口")
public class LocaleventController {
    @Autowired
    private TbLocaleventService localeventService;


//--------------------------- 普通用户 -------------------------------------


    /**
     * 获取所有事件
     *
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see ResponseResult
     * @since version
     */
    @GetMapping("/getAllEvents")
    @ApiOperation(value = "普通用户浏览接口", produces = "application/json", httpMethod = "GET")
    public ResponseResult getAllEvents() {
        return localeventService.getAllEvents();
    }

    /**
     * 发布文化信息
     *
     * @param tbLocaleventDto 结核病本地事件 DTO
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see TbLocaleventDto
     * @see ResponseResult
     * @since version
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加本地活动接口", produces = "application/json", httpMethod = "POST")
    public ResponseResult add(@RequestBody TbLocaleventDto tbLocaleventDto) {
        return localeventService.add(tbLocaleventDto);
    }

    /**
     * 保存草稿事件
     *
     * @param tbLocalevent 结核病本地事件
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see TbLocalevent
     * @see ResponseResult
     * @since version
     */
    @PostMapping("/saveDraftEvent")
    @ApiOperation(value = "将活动信息保存为草稿")
    public ResponseResult saveDraftEvent(@RequestBody TbLocalevent tbLocalevent) {
        return localeventService.saveDraftEvent(tbLocalevent);
    }

    /**
     * 更新区域性信息
     *
     * @param tbLocaleventDto 结核病本地事件 DTO
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see TbLocaleventDto
     * @see ResponseResult
     * @since version
     */
    @PutMapping("/updateEventInfo")
    @ApiOperation(value = "修改活动信息接口", produces = "application/json", httpMethod = "PUT")
    public ResponseResult updateEventInfo(@RequestBody TbLocaleventDto tbLocaleventDto) {
        return localeventService.updateEventInfo(tbLocaleventDto);
    }

    /**
     * 按用户名获取事件信息
     *
     * @param userName 用户名
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see String
     * @see ResponseResult
     * @since version
     */
    @GetMapping("/getEventInfoByUserName")
    @ApiOperation(value = "根据用户名查找对应用户发布的信息", produces = "application/json", httpMethod = "GET")
    public ResponseResult getEventInfoByUserName(@RequestParam("userName") String userName) {
        return localeventService.getEventInfoByUserName(userName);
    }


    /**
     * 将草稿发布
     *
     * @param eventId 区域性 ID
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see Integer
     * @see ResponseResult
     * @since version
     */
    @PutMapping("/putEvent")
    @ApiOperation(value = "将保存的草稿发布", produces = "application/json", httpMethod = "PUT")
    public ResponseResult putEvent(@RequestParam("eventId") Integer eventId) {
        return localeventService.putCulture(eventId);
    }

    /**
     * 删除
     *
     * @param eventId 事件 ID
     * @return @return {@code ResponseResult }
     * @author $USER$
     * @date 2024/03/29
     * @see Integer
     * @see ResponseResult
     * @since version
     */
    @DeleteMapping("/localEventDelete/{eventId}")
    @ApiOperation(value = "删除自己发布的活动信息接口", produces = "application/json", httpMethod = "DELETE")
    public ResponseResult delete(@PathVariable Integer eventId) {
        return localeventService.delete(eventId);

    }

    @GetMapping("/myEvent")
    @ApiOperation(value = "查找用户自己发布的活动信息", produces = "application/json", httpMethod = "GET")
    public ResponseResult getMyEvents() {
        return localeventService.getMyEvent();
    }

    @GetMapping("/mysaveDraftEvent")
    @ApiOperation(value = "用户查看自己保存的文化信息草稿", produces = "application/json", httpMethod = "GET")
    public ResponseResult getMySaveDraftEvents() {
        return localeventService.getMySaveDraftEvent();
    }




    //----------------------------管理员接口------------------------------------
    @PutMapping("/checkLocalEvent")
    @ApiOperation(value = "管理员审核本地活动接口",produces = "application/json",httpMethod = "PUT")
    public ResponseResult  checkLocalCulture(@RequestParam("eventId") int eventId, @RequestParam("status") String status){
        return localeventService.checkLocalEvent(eventId, status);
    }


    @GetMapping("/GetAll")
    @ApiOperation(value = "管理员查看本地所有活动信息接口",produces = "application/json",httpMethod = "GET")
    public  ResponseResult  getAllCultures(@RequestParam(value = "current", defaultValue = "1") Integer current, @RequestParam(value = "total",defaultValue = "10") Integer total){
        return  localeventService.getAllEvent(current,total);
    }

    //管理员删除文化信息
    @DeleteMapping("delEventByAdmin")
    @ApiOperation(value = "管理员删除文化信息",produces = "application/json",httpMethod = "DELETE")
    public ResponseResult deleteCulturesByAdmin(@RequestParam("eventId") Integer eventId ){
        return  localeventService.deleteEventsByAdmin(eventId);
    }


}